<?php

/**
 * 第三方登陆管理
 * @author Ice <iceinto@mallog.com.cn>
 */
class OAuthModel extends BaseModel {
	public $tableName  = 'oauth';
	public function getOne($site, $openid){
		$map = array();
		$map['site'] = $site;
		$map['openid'] = $openid;
		return $this->where($map)->find();
	}

	public function getUserBind($uid){
		$map = array();
		$map['uid'] = $uid;
		return $this->where($map)->select();
	}

	public function getUserOneBind($uid, $site){
		$map = array();
		$map['uid'] = $uid;
		$map['site'] = $site;
		return $this->where($map)->find();
	}

	/**
	 * 获取用户绑定信息
	 * @param int $uid
	 */
	public function getOauth($uid){
		$map = array();
		$map['uid'] = $uid;
		$oauth = $this->getListByWhere($map);
		foreach($oauth as $k=>$o){
			$oauth[$o['site']] = $o;
			unset($oauth[$k]);
		}
		return $oauth;
	}
}